﻿<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>首页</title>
    <meta name="keywords" content="中电金信有限公司" />
    <meta name="description" content="中电金信有限公司" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="generator" content="" data-variable="/,cn,10001,,10001,res032" />
    <link rel='stylesheet' href='css/index.css'>

    <style>
        .imgstyle {
            width: 100%;
            /* 或者使用具体的宽度值 */
            height: 200px;
            /* 确保高度自适应 */
        }
    </style>
</head>

<body class="met-navfixed">
    <header id="header" class="header-fixed">
        <div class="container">
            <ul class="head-list">
                <li class="left tel">
                    <img src="images/1514354107.png" alt="">
                    <span>
                        全国咨询热线：
                    </span>
                    <em>
                        400-123-4567
                    </em>
                </li>
                <li class="right">
                    <ul>
                        <li>
                            <img src="images/1514355047.png" alt="一流的服务">
                            <span>
                                一流的服务
                            </span>
                        </li>
                        <li>
                            <img src="images/1514354958.png" alt="透明的价格">
                            <span>
                                透明的价格
                            </span>
                        </li>
                        <li>
                            <img src="images/1514354817.png" alt="重信守誉">
                            <span>
                                重信守誉
                            </span>
                        </li>
                        <li>
                            <img src="images/1514354461.png" alt="优质的技师">
                            <span>
                                优质的技师
                            </span>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </header>
    <nav class="navbar navbar-default met-nav navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="row">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle hamburger hamburger-close collapsed"
                        data-target="#navbar-default-collapse" data-toggle="collapse">
                        <span class="sr-only">
                            Toggle navigation
                        </span>
                        <span class="hamburger-bar">
                        </span>
                    </button>
                    <a href="#" ​ class="navbar-brand navbar-logo vertical-align" title="中电金信有限公司(自适应手机端)">
                        <h1 class='hide'>
                            中电金信有限公司(自适应手机端)
                        </h1>
                        <div class="vertical-align-middle">
                            <img src="images/logom.png" alt="中电金信有限公司(自适应手机端)" title="中电金信有限公司(自适应手机端)" />
                        </div>
                    </a>
                    <h2 class='hide'>
                    </h2>
                </div>
                <div class="collapse navbar-collapse navbar-collapse-toolbar" id="navbar-default-collapse">
                    <ul class="nav navbar-nav navbar-right navlist">
                        <li>
                            <a href="index.html" ​ title="网站首页" class="link  active">
                                网站首页
                            </a>
                        </li>
                        <li class="dropdown margin-left-20">
                            <a class="dropdown-toggle link " data-toggle="dropdown" data-hover="dropdown"
                                aria-expanded="false" href="about.html">
                                关于我们
                                <span class="caret">
                                </span>
                            </a>
                            <ul class="dropdown-menu dropdown-menu-right bullet">
                                <li>
                                    <a href="about.html" ​ class="" title="公司简介">
                                        公司简介
                                    </a>
                                </li>
                                <li>
                                    <a href="message.html" ​ class="" title="在线留言">
                                        在线留言
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown margin-left-20">
                            <a class="dropdown-toggle link " data-toggle="dropdown" data-hover="dropdown"
                                aria-expanded="false" href="product.html">
                                优质水会
                                <span class="caret">
                                </span>
                            </a>
                            <ul class="dropdown-menu dropdown-menu-right bullet">
                                <li>
                                    <a href="productcate1.html" ​ class="" title="丽丝">
                                        丽丝水会
                                    </a>
                                </li>
                                <li>
                                    <a href="productcate2.html" ​ class="" title="威美斯">
                                        威美斯水会
                                    </a>
                                </li>
                                <li>
                                    <a href="productcate3.html" ​ class="" title="贝帮">
                                        贝帮水会
                                    </a>
                                </li>
                                <li>
                                    <a href="productcate4.html" ​ class="" title="月荷湾">
                                        月荷湾水会
                                    </a>
                                </li>
                                <li>
                                    <a href="productcate5.html" ​ class="" title="月荷湾">
                                        其它水会
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown margin-left-20">
                            <a class=" link " href="contact.html">
                                联系我们
                            </a>
                            <ul class="dropdown-menu dropdown-menu-right bullet">
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
    <div class="met-banner" data-height='' style=''>
        <div class="slick-slide">
            <img class="cover-image" src="images/lisi1.jpg" sizes="(max-width: 767px) 767px" alt="幻灯二">
        </div>
        <div class="slick-slide">
            <img class="cover-image" src="images/weimeisi1.jpg" sizes="(max-width: 767px) 767px" alt="幻灯一">
        </div>
        <div class="slick-slide">
            <img class="cover-image" src="images/beibang1.jpg" sizes="(max-width: 767px) 767px" alt="幻灯一">
        </div>
    </div>

    <!-- 优质技师区域 -->
    <div class="recommend-section premium-section">
        <h2 class="section-title">
            <i class="fas fa-crown"></i>优质技师推荐
        </h2>
        <div id="premium-technicians" class="cards-container">
            <!-- 动态加载内容 -->
        </div>
    </div>

    <!-- 今日推荐区域 -->
    <div class="recommend-section today-section">
        <h2 class="section-title">
            <i class="fas fa-fire"></i>今日热门推荐
        </h2>
        <div id="today-technicians" class="cards-container">
            <!-- 动态加载内容 -->
        </div>
    </div>

    <footer>
        <div class="container text-center">
            <p>
                CopyRight &copy; 2020-2030 中电金信有限公司 版权所有
            </p>
            <p>
                ICP备XXXXXXXX号
            </p>
        </div>
    </footer>
    <button type="button" class="btn btn-icon btn-primary btn-squared met-scroll-top hide">
        <i class="icon wb-chevron-up" aria-hidden="true">
        </i>
    </button>
    <script src="js/index.js"></script>

    <script>
        // 配置常量
        const API_CONFIG = {
            baseUrl: 'http://47.108.230.236:9010',
            endpoint: '/html/list',
            staticBase: '/profile' // 若依框架静态资源映射路径
        };

        // 主初始化函数
        document.addEventListener('DOMContentLoaded', async () => {
            try {
                const [premiumTechs, todayTechs] = await Promise.all([
                    fetchTechnicians('1'),
                    fetchTechnicians('2')
                ]);

                renderTechnicians(premiumTechs, 'premium-technicians', 'premium-card', '优质推荐');
                renderTechnicians(todayTechs, 'today-technicians', 'today-card', '今日热门');
            } catch (error) {
                console.error('初始化失败:', error);
            }
        });

        // 获取技师数据
        async function fetchTechnicians(type) {
            try {
                const response = await fetch(`${API_CONFIG.baseUrl}${API_CONFIG.endpoint}`, {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ technicianType: type })
                });
                if (!response.ok) throw new Error(`HTTP ${response.status}`);
                const { data } = await response.json();
                return data || [];
            } catch (error) {
                console.error(`获取${type === '1' ? '优质技师' : '今日推荐'}数据失败:`, error);
                return [];
            }
        }

        /**
         * 渲染技师卡片（移除了默认图片逻辑）
         */
        function renderTechnicians(techs, containerId, cardClass, badgeText) {
            const container = document.getElementById(containerId);
            if (!container) return;

            container.innerHTML = '';

            techs.forEach(tech => {
                const card = document.createElement('div');
                card.className = `recommend-card ${cardClass}`;

                // 优化点：路径处理逻辑
                const getCleanImagePath = (path) => {
                    if (!path) return '';
                    // 统一处理各种路径格式
                    return path.replace(/\\/g, '/')
                        .replace(/\/{2,}/g, '/')
                        .replace(/^\/profile/, '');
                };

                // 生成最终图片URL（移除了默认图片回退）
                const imageUrl = tech.mainImg
                    ? `${API_CONFIG.baseUrl}${API_CONFIG.staticBase}${getCleanImagePath(tech.mainImg)}`
                    : ''; // 留空而不是使用默认图片

                card.innerHTML = `
                    <img class="card-img" 
                         src="${imageUrl}" 
                         alt="${tech.name || '技师照片'}">
                    <div class="card-body">
                        <h3 class="card-title">${tech.name || '未命名技师'}</h3>
                        <p class="card-desc">${tech.message || '专业服务，品质保证'}</p>
                        <div class="card-footer">
                            <span class="card-badge">${badgeText}</span>
                            <a href="productshow.html?id=${tech.id}" class="card-btn">查看详情</a>
                        </div>
                    </div>
                `;
                container.appendChild(card);
            });
        }
    </script>

    <style>
        .copyrights {
            text-indent: -9999px;
            height: 0;
            line-height: 0;
            font-size: 0;
            overflow: hidden;
        }

        /* 整体布局样式 */
        body {
            font-family: Arial, sans-serif;
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }

        /* 推荐区域公共样式 */
        .recommend-section {
            margin-bottom: 30px;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .section-title {
            font-size: 22px;
            margin: 0 0 20px 0;
            padding: 0 0 10px 0;
            border-bottom: 2px solid;
            display: flex;
            align-items: center;
            width: 100%;
            box-sizing: border-box;
        }

        .section-title i {
            margin-right: 10px;
            font-size: 24px;
        }

        /* 优质技师区域 */
        .premium-section .section-title {
            color: #1890ff;
            border-color: #1890ff;
        }

        /* 今日推荐区域 */
        .today-section .section-title {
            color: #ff4d4f;
            border-color: #ff4d4f;
        }

        /* 卡片容器 - 6列布局 */
        .cards-container {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 15px;
        }

        /* 卡片公共样式 */
        .recommend-card {
            border-radius: 8px;
            overflow: hidden;
            background: white;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s;
        }

        .recommend-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .card-img {
            width: 100%;
            height: 140px;
            object-fit: cover;
        }

        .card-body {
            padding: 12px;
        }

        .card-title {
            font-size: 16px;
            margin: 0 0 6px;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .card-desc {
            color: #666;
            font-size: 13px;
            margin-bottom: 12px;
            height: 36px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .card-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .card-badge {
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 11px;
            font-weight: bold;
        }

        .card-btn {
            padding: 5px 8px;
            /* 减小左右padding */
            border-radius: 3px;
            font-size: 13px;
            text-decoration: none;
            font-weight: bold;
            transition: all 0.3s;
            white-space: nowrap;
            /* 防止按钮文字换行 */
        }

        /* 优质卡片特定样式 */
        .premium-card .card-badge {
            background: #e6f7ff;
            color: #1890ff;
        }

        .premium-card .card-btn {
            background: #1890ff;
            color: white;
            border: 1px solid #1890ff;
        }

        .premium-card .card-btn:hover {
            background: #40a9ff;
            border-color: #40a9ff;
        }

        /* 今日推荐卡片特定样式 */
        .today-card .card-badge {
            background: #fff1f0;
            color: #ff4d4f;
        }

        .today-card .card-btn {
            background: #ff4d4f;
            color: white;
            border: 1px solid #ff4d4f;
        }

        .today-card .card-btn:hover {
            background: #ff7875;
            border-color: #ff7875;
        }

        /* ===== 移动端专属样式（768px以下） ===== */
        @media (max-width: 768px) {

            /* 1. 基础布局重置 */
            .recommend-section {
                padding: 20px 0 !important;
                width: 318px !important;
                /* 306内容区 + 12px安全边距 */
                margin: 0 auto !important;
                box-sizing: border-box;
            }

            /* 2. 标题下划线系统 */
            .section-title {
                width: 306px !important;
                /* 147x2 + 12gap */
                margin: 0 auto 15px !important;
                padding-bottom: 10px;
                border-bottom: 2px solid;
                text-align: left;
                position: relative;
                left: -6px;
                /* 视觉补偿 */
                font-size: 16px !important;
            }

            /* 3. 卡片容器系统 */
            .cards-container {
                display: grid;
                grid-template-columns: repeat(2, 147px) !important;
                width: 306px !important;
                margin: 0 auto !important;
                gap: 12px !important;
                padding: 0 !important;
            }

            /* 4. 卡片通用样式 */
            .recommend-card {
                width: 147px !important;
                min-height: 210px !important;
                border-radius: 8px;
                overflow: hidden;
                background: white;
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
                transition: transform 0.3s;
            }

            .recommend-card:hover {
                transform: translateY(-3px);
            }

            /* 5. 卡片图片系统 */
            .card-img {
                width: 100%;
                height: 110px !important;
                /* 4:3比例 */
                object-fit: cover;
            }

            /* 6. 卡片内容区域（重点修改描述部分） */
            .card-body {
                padding: 12px 10px !important;
            }

            .card-title {
                font-size: 14px !important;
                margin: 0 0 6px;
                color: #333;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .card-desc {
                color: #666;
                font-size: 11px !important;
                margin-bottom: 10px;
                height: 32px !important;
                /* 精确控制2行高度 */
                line-height: 1.4 !important;
                overflow: hidden !important;
                display: -webkit-box;
                -webkit-line-clamp: 2 !important;
                /* 强制2行截断 */
                -webkit-box-orient: vertical;
                text-overflow: ellipsis;
                word-break: break-word;
            }

            /* 7. 卡片底部按钮系统 */
            .card-footer {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 6px 0 0 !important;
            }

            .card-badge {
                padding: 2px 6px;
                border-radius: 3px;
                font-size: 10px !important;
                font-weight: bold;
            }

            .card-btn {
                min-width: 50px !important;
                height: 24px;
                padding: 0 6px !important;
                border-radius: 3px;
                font-size: 10px !important;
                text-decoration: none;
                font-weight: bold;
                line-height: 24px;
                white-space: nowrap;
                transition: all 0.3s;
            }

            /* 8. 主题色配置 */
            /* 优质技师主题 */
            .premium-section .section-title {
                color: #1890ff;
                border-color: #1890ff;
            }

            .premium-card .card-badge {
                background: #e6f7ff;
                color: #1890ff;
            }

            .premium-card .card-btn {
                background: #1890ff;
                color: white;
                border: 1px solid #1890ff;
            }

            /* 今日推荐主题 */
            .today-section .section-title {
                color: #ff4d4f;
                border-color: #ff4d4f;
            }

            .today-card .card-badge {
                background: #fff1f0;
                color: #ff4d4f;
            }

            .today-card .card-btn {
                background: #ff4d4f;
                color: white;
                border: 1px solid #ff4d4f;
            }
        }

        /* ===== 超小屏适配（375px以下） ===== */
        @media (max-width: 375px) {
            .recommend-section {
                width: 100% !important;
                padding: 20px 12px !important;
            }

            .section-title {
                width: 100% !important;
                left: 0;
                text-align: center;
                background: linear-gradient(to right,
                        transparent 0%,
                        transparent calc(50% - 153px),
                        currentColor calc(50% - 153px),
                        currentColor calc(50% + 153px),
                        transparent calc(50% + 153px));
                background-position: bottom;
                background-repeat: no-repeat;
                background-size: 100% 2px;
                border-bottom: none !important;
                padding-bottom: 12px !important;
            }

            .cards-container {
                width: 100% !important;
                grid-template-columns: repeat(2, calc(50% - 6px)) !important;
            }

            .recommend-card {
                width: 100% !important;
            }

            .card-desc {
                height: 30px !important;
                /* 小屏微调行高 */
            }
        }
    </style>
    
</body>

</html>